#include <stdio.h>

int main(){
    int a = 0;
    int b = 0;
    scanf("%d %d",&a,&b);
    //求最大公约数
    //辗转相除法
    //(a,b)->(a%b,b)...
    //如果a<b：a=18,b=24,=>a%b = 18==>a=24,b=18
    int c = 0;
    while(c = a % b){
        a = b;
        b = c;
    }
    printf("%d",b);

    return 0;
}